"""
RagFlow 客户端 GUI 对话功能模块
"""

from PySide6.QtWidgets import QWidget, QVBoxLayout
from ragflow_client.gui.features.base_feature import BaseFeature
from ragflow_client.gui.components.dialogs import ChatDialog


class ChatFeature(BaseFeature):
    """对话功能类"""
    
    def __init__(self, parent=None):
        """初始化对话功能"""
        super().__init__(parent)
    
    def execute(self):
        """执行对话功能"""
        # 验证API配置
        if not self.validate_api_config():
            return
        
        # 获取API信息
        api_url, api_key, kb_id, debug = self.get_api_info()
        
        # 创建对话对话框
        dialog = ChatDialog(self.parent, api_url, api_key, kb_id, debug)
        
        # 创建内容部件
        content_widget = QWidget()
        layout = QVBoxLayout(content_widget)
        layout.addWidget(dialog)
        
        # 创建窗口
        self.window = self.create_window("对话", content_widget)
        self.window.show()
